﻿using Framework.Exceptions;
using Interfaces.Validation.Repositories;
using Interfaces.Validation.Services;

namespace BusinessLogic.Services.Validation
{
    public class UserValidationService : IUserValidationService
    {
        private readonly IUserValidationRepository _userValidationRepository;
        
        public UserValidationService(IUserValidationRepository userValidationRepository)
        {
            _userValidationRepository = userValidationRepository;
        }
        
        public bool IsEmailExists(string email)
        {
            return ExceptionHandlingManager.Process(() => _userValidationRepository.IsEmailExists(email), PolicyNames.DALPolicy);
        }

        public bool IsUserNameExists(string userName)
        {
            return ExceptionHandlingManager.Process(() => _userValidationRepository.IsUserNameExists(userName), PolicyNames.DALPolicy);
        }
    }
}
